package com.link.base.base.invloc.controller;

import com.link.base.base.invloc.model.Invloc;
import com.link.base.base.invloc.service.InvlocService;
import com.link.core.cllog.LCLogger;
import com.link.core.basic.annotations.JsonParam;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.query.Filter;
import com.link.core.basic.query.QueryParams;
import com.link.core.basic.service.BasicService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author: unknown
 * created: unknown
 * comments:
 */
@Controller
@RequestMapping("/link/invloc")
public class InvlocController extends BasicController<Invloc> {

    @Resource
    private InvlocService invlocService;

    @Override
    public BasicService<Invloc> getBasicService() throws Exception {
        return invlocService;
    }

    @RequestMapping(value = "/edit/{id}")
    public String edit(@PathVariable Long id, @JsonParam QueryParams qps, HttpSession session,
                       HttpServletRequest request, HttpServletResponse response) {
        qps.addFilter(new Filter("id", String.valueOf(id)));
        Invloc record = new Invloc();
        record.setId(id);
        Invloc result = null;
        try {
            //通过id查询审批流程
            result = invlocService.queryById(record);
        } catch (Exception e) {
            LCLogger.withException(e);
        }
        request.setAttribute("result", result);
        return "invloc/invlocInfo";
    }

}
